import pymysql
import psycopg2

class MySQLAdapter(DatabaseAdapter):
    def connect(self, db_config):
        self.conn = pymysql.connect(**db_config)

    def execute_query(self, sql, params=None):
        with self.conn.cursor() as cursor:
            cursor.execute(sql, params or ())
            self.conn.commit()

    def fetch_data(self, sql, params=None):
        with self.conn.cursor() as cursor:
            cursor.execute(sql, params or ())
            return cursor.fetchall()

class PostgreSQLAdapter(DatabaseAdapter):
    def connect(self, db_config):
        self.conn = psycopg2.connect(**db_config)

    def execute_query(self, sql, params=None):
        with self.conn.cursor() as cursor:
            cursor.execute(sql, params or ())
            self.conn.commit()

    def fetch_data(self, sql, params=None):
        with self.conn.cursor() as cursor:
            cursor.execute(sql, params or ())
            return cursor.fetchall()